﻿using BenCaoXuan.Infrastructure.Attr;
using BenCaoXuan.Infrastructure.Dto.Middle.Request.Appointment;
using BenCaoXuan.Infrastructure.Dto;
using BenCaoXuan.Service.Instance.middle;
using BenCaoXuan.Service.Interface.middle;
using Microsoft.AspNetCore.Mvc;
using BenCaoXuan.Infrastructure.EFCore.MySql;
using BenCaoXuan.Infrastructure.Dto.Middle.Response.Product;

namespace BenCaoXuan.Api.Admin.Controllers.middle
{
    [ApiGroup("Middle(移动端模块)")]
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AppointmentController : ControllerBase
    {
        private readonly I_Appointment_Service _appointment_Service;

        public AppointmentController(I_Appointment_Service appointment_Service)
        {
            _appointment_Service = appointment_Service;
        }

        /// <summary>
        /// 获取客户最近三条预约记录
        /// </summary>
        /// <param name="customerId">客户ID</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Get_Customer_LatestThreeAppointments(string? customerId)
        {
            var result = await _appointment_Service.Get_Customer_LatestThreeAppointments(customerId);
            return Ok(result);
        }

        /// <summary>
        /// 重新预约
        /// </summary>
        /// <param name="appointmentId"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Rebook_Appointment(string? appointmentId)
        {
            var result = await _appointment_Service.Rebook_Appointment(appointmentId);
            return Ok(result);
        }

        /// <summary>
        /// 取消预约
        /// </summary>
        /// <param name="appointmentId"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Cancel_Appointment(string? appointmentId)
        {
            var result = await _appointment_Service.Cancel_Appointment(appointmentId);
            return Ok(result);
        }

        /// <summary>
        /// 获取客户的所有预约
        /// </summary>
        /// <param name="customerId"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Get_Customer_Appointment(string? customerId)
        {
            var result = await _appointment_Service.Get_Customer_Appointment(customerId);
            return Ok(result);
        }
        /// <summary>
        /// 查询预约详情
        /// </summary>
        /// <param name="appointmentId"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Get_AppointmentDetails(string? appointmentId, bool isProduct)
        {
            var result = await _appointment_Service.Get_AppointmentDetails(appointmentId, isProduct);
            return Ok(result);
        }

        /// <summary>
        /// 立即预约-套餐
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Add_Appointment([FromBody] Appointment_Request_Dto dto)
        {
            var result = await _appointment_Service.Add_Appointment(dto);
            return Ok(result);
        }
        /// <summary>
        /// 立即预约-产品
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Add_Product_Appointment([FromBody] Appointment_Request_Dto dto)
        {
            var result = await _appointment_Service.Add_Product_Appointment(dto);
            return Ok(result);
        }

    }
}
